<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ONVIF设备管理系统</title>
    <meta name="description" content="ONVIF设备管理和视频流播放系统" />
    <meta name="keywords" content="ONVIF,设备管理,视频监控,流媒体" />
    <meta name="author" content="wondertek" />
    
    <!-- Preload critical resources -->
    <link rel="preload" href="/src/main.js" as="script" crossorigin />
    <link rel="preload" href="/src/App.vue" as="script" crossorigin />
    
    <!-- Element Plus Icons -->
    <link rel="preload" href="https://unpkg.com/@element-plus/icons-vue@latest/dist/index.css" as="style" />
    
    <!-- Video.js CSS -->
    <link rel="preload" href="https://unpkg.com/video.js@8/dist/video-js.css" as="style" />
    
    <style>
      /* Loading styles */
      #loading {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
        transition: opacity 0.3s ease;
      }
      
      .loading-content {
        text-align: center;
        color: white;
      }
      
      .loading-spinner {
        width: 50px;
        height: 50px;
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-top: 3px solid white;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin: 0 auto 20px;
      }
      
      @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
      }
      
      .loading-text {
        font-size: 18px;
        font-weight: 500;
        margin-bottom: 10px;
      }
      
      .loading-subtitle {
        font-size: 14px;
        opacity: 0.8;
      }
      
      /* Reset styles */
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      
      html, body {
        height: 100%;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
      
      #app {
        height: 100%;
        overflow: hidden;
      }
      
      /* Scrollbar styles */
      ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
      }
      
      ::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
      }
      
      ::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
      }
      
      ::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
      }
    </style>
  </head>
  <body>
    <!-- Loading screen -->
    <div id="loading">
      <div class="loading-content">
        <div class="loading-spinner"></div>
        <div class="loading-text">ONVIF设备管理系统</div>
        <div class="loading-subtitle">正在加载中...</div>
      </div>
    </div>
    
    <!-- Vue app container -->
    <div id="app"></div>
    
    <!-- Main script -->
    <script type="module" src="/src/main.js"></script>
    
    <!-- Hide loading screen when app is ready -->
    <script>
      window.addEventListener('load', function() {
        setTimeout(function() {
          const loading = document.getElementById('loading');
          if (loading) {
            loading.style.opacity = '0';
            setTimeout(function() {
              loading.style.display = 'none';
            }, 300);
          }
        }, 1000);
      });
      
      // Error handling
      window.addEventListener('error', function(e) {
        console.error('Application error:', e.error);
        const loading = document.getElementById('loading');
        if (loading) {
          loading.innerHTML = `
            <div class="loading-content">
              <div style="color: #ff6b6b; font-size: 24px; margin-bottom: 20px;">⚠️</div>
              <div class="loading-text">加载失败</div>
              <div class="loading-subtitle">请刷新页面重试</div>
              <button onclick="location.reload()" style="
                margin-top: 20px;
                padding: 10px 20px;
                background: white;
                border: none;
                border-radius: 4px;
                cursor: pointer;
                font-size: 14px;
              ">刷新页面</button>
            </div>
          `;
        }
      });
    </script>
  </body>
</html>